const variables = this.pageObj.getVariables();
const table = this.pageObj.getApiWidgetByAliasName('选择系统表格')?.widgetObj

const sysEnvType = variables.find(v => v.name === 'sysEnvType')?.value || '';
const userId = variables.find(v => v.name === 'userId')?.value || '';
const prefix = variables.find(v => v.name === 'environmentType')?.value || '';

const basics = BasicServices.getInstance(prefix)

basics.getRolesByUserId(userId).then(({ code, data, userInfo } = {}) => {
    if (sysEnvType === "gt") {
        if (userInfo?.roleInfos) {
            data = userInfo.roleInfos.map(item => {
                return {
                    ...item,
                    careerName: item.roleName,
                    careerCode: item.roleId,
                }
            });

        }
    } else {
        if (code === 200 && Array.isArray(data)) {
            data = data.map(item => ({ ...item, careerName: item.roleName, careerCode: item.roleCode }))
        }
    }

    if (data) {
        table.setData([{ data }]);
        table.render();
    }
})

